<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>订舱业务管理</title>
    <s:head/>

    <!-- 自定义style -->
    <style>
        .dataTB {
            width: 100%;
            border: 1px solid #ccc;
            line-height: 30px;
        }

        td.dataTD {
            font-weight: bold;
        }
    </style>
    <!-- 自定义style -->
    <!-- 自定义script -->
    <script type="text/javascript">
        $(function () {
            initFuncButton();
        });

        function initFuncButton() {
            $("button").attr("disabled", true);
            var bookingState = "${booking.bookingState}";
            if (bookingState == "BS00" || bookingState == "BS03") {//草稿、驳回
                $("#bizModifyBtn").attr("disabled", false);
                $("#bizConfirmBtn").attr("disabled", false);
            }
            $("#returnBtn").attr("disabled", false);
        }

        function bizModify() {
            var id = "${booking.id}";
            var data = "id=" + id;
            $.ajax({
                       url: "booking-checkBizModify",
                       dataType: "json",
                       data: data,
                       success: function (data) {
                           if (!data) {
                               return;
                           }
                           var msg = data.msg ? $.parseJSON(data.msg) : "";
                           if (msg.state == 1) {
                               jw.confirm("确定要修改该业务?", function () {
                                              //window.location.href="booking-bizModify?booking.id="+id;
                                              window.location.href =
                                                      "business-updateSingle?id=" + id + "&singleType=F";
                                          },
                                          function () {
                                              return;
                                          });
                           }
                           else if (msg !== undefined && msg != "" && msg.state == 0) {
                               jw.alert("只有处于草稿和驳回状态的业务才可以修改。");
                           }
                           else {
                               jw.alert(msg.msg);
                           }
                       }
                   });
        }

        function bizConfirm() {
            var id = "${booking.id}";
            var iddata = "id=" + id;
            $.ajax({
                       url: "booking-checkBizConfirm",
                       dataType: "json",
                       data: iddata,
                       success: function (data) {
                           if (!data) {
                               return;
                           }
                           var msg = data.msg ? $.parseJSON(data.msg) : "";
                           if (msg.state == 1) {
                               jw.confirm("确定要提交该业务?", function () {
                                              $.ajax({
                                                         url: "booking-bizConfirm",
                                                         dataType: "json",
                                                         data: iddata,
                                                         success: function (data) {
                                                             jw.alert(msg.msg);
                                                             window.location.href = "booking-main";
                                                         }
                                                     });
                                          },
                                          function () {
                                              return;
                                          });
                           }
                           else if (msg !== undefined && msg != "" && msg.state == 0) {
                               jw.alert("只有处于草稿和驳回状态的业务才可以提交。");
                           }
                           else {
                               jw.alert(msg.msg);
                           }
                       }
                   });
        }

    </script>

</head>
<body>
<fieldset>
    <legend>供应商信息：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">公司名称/联系人：</td>
            <td class="dataTD">
                <s:property value="booking.supCompany.name"/>/<s:property
                    value="booking.supCompany.contactor"/>
            </td>
        </tr>
        <tr>
            <td class="labelTD">地址：</td>
            <td class="dataTD"><s:property value="booking.supCompany.address"/></td>
            <td class="labelTD">电话：</td>
            <td class="dataTD"><s:property value="booking.supCompany.phone"/></td>
            <td class="labelTD">传真：</td>
            <td class="dataTD"><s:property value="booking.supCompany.fax"/></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>出口公司：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">公司名称/联系人：</td>
            <td class="dataTD">
                <s:property value="booking.shipper.company"/>/<s:property
                    value="booking.shipper.name"/>
            </td>
        </tr>
        <tr>
            <td class="labelTD">地址：</td>
            <td class="dataTD"><s:property value="booking.shipper.address"/></td>
            <td class="labelTD">电话：</td>
            <td class="dataTD"><s:property value="booking.shipper.phone"/></td>
            <td class="labelTD">传真：</td>
            <td class="dataTD"><s:property value="booking.shipper.fax"/></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>收货公司：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">公司名称/联系人：</td>
            <td class="dataTD">
                <s:property value="booking.consignee.company"/>/<s:property
                    value="booking.consignee.name"/>
            </td>
        </tr>
        <tr>
            <td class="labelTD">地址：</td>
            <td class="dataTD"><s:property value="booking.consignee.address"/></td>
            <td class="labelTD">电话：</td>
            <td class="dataTD"><s:property value="booking.consignee.phone"/></td>
            <td class="labelTD">传真：</td>
            <td class="dataTD"><s:property value="booking.consignee.fax"/></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>托运信息：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">业务类型：</td>
            <td class="dataTD"><s:property value="businessDto.bookingBusinessType"/></td>
            <td class="labelTD">大船公司：</td>
            <td class="dataTD"><s:property value="booking.shipping.name"/></td>
            <td class="labelTD">起运港：</td>
            <td class="dataTD"><s:property value="businessDto.bookingStPort"/></td>
            <td class="labelTD">目的港：</td>
            <td class="dataTD"><s:property value="businessDto.bookingArPort"/></td>
        </tr>
        <tr>
            <td class="labelTD">船期要求：</td>
            <%-- 		<td class="dataTD"><s:date name="booking.shipDate" format="yyyy-MM-dd"/></td> --%>
            <td class="dataTD"><s:property value="booking.shipDate"/></td>
            <td class="labelTD">合作价格：</td>
            <td class="dataTD"><s:property value="booking.price"/></td>
            <td class="labelTD">备注：</td>
            <td class="dataTD"><s:property value="booking.remark"/></td>
            <td class="labelTD"></td>
            <td class="dataTD"></td>
        </tr>
    </table>
</fieldset>
<fieldset>
    <legend>货物信息：</legend>
    <table class="dataTB">
        <tr>
            <td class="labelTD">货物名称</td>
            <td class="labelTD">毛重/净重/KG</td>
            <td class="labelTD">体积/立方米</td>
            <td class="labelTD">所需柜量</td>
        </tr>
        <s:iterator value="booking.goodses" var="goods">
            <tr>
                <td class="dataTD"><s:property value="#goods.name"/></td>
                <td class="dataTD"><s:property value="#goods.gWeight"/>/<s:property
                        value="#goods.nWeight"/></td>
                <td class="dataTD"><s:property value="#goods.volume"/></td>
                <td class="dataTD"><s:property value="#goods.ctNumType"/></td>
            </tr>
        </s:iterator>
    </table>
</fieldset>
<fieldset>
    <legend>操作选项</legend>
    <button ID="bizModifyBtn" onclick="bizModify();">修改业务</button>
    <button ID="bizConfirmBtn" onclick="bizConfirm();">提交业务</button>
    <button id="returnBtn" onclick="location.href='booking-main';">返回</button>
</fieldset>
</body>
</html>
